package com.example.tkserver.dao;

import com.example.tkserver.entity.Article;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleDao {

    @Insert("INSERT INTO article(uid,title,content,images,articleTime) " +
            "VALUES(#{uid},#{title},#{content},#{images},now())")
    public int publishArticle(Article article);

    @Select("SELECT COUNT(*) FROM article")
    public int getRecommendArticleNum();

    @Select("SELECT " +
            "u.uid,u.avatarUrl,u.nickName,unix_timestamp(a.articleTime) datetime,a.* " +
            "FROM article a,user u " +
            "LIMIT #{start},#{end}")
    public List<Article> getRecommendArticle(int start,int end);
}
